<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // console.log(location.search)
      // console.log(location.search.slice(1))
      // let arr = location.search.slice(1).split('&')
      // console.log(arr)
      // let obj = {}
      // arr.forEach(item => {
      //   let [k, value] = item.split('=')
      //   obj[k] = value
      // })
      // console.log(obj)
      // let str = '?name=zs&age=18&gender=男'
      // q = {}
      // location.search.replace(/([^?&=]+)=([^&]+)/g, (_, k, v, i) => {

      //   q[k] = v
      // })
      // console.log(q)

      // let reg = /([^?&=]+)=([^&]+)/g
      // console.log(reg.exec(str))
      // // console.log(reg.exec(str))
      // // console.log(reg.exec(str))
      // console.log(str)

      // console.log((_=>[..."`1234567890-=~~QWERTYUIOP[]\\~ASDFGHJKL;'~~ZXCVBNM,./~"].map(x=>(o+=`/${b='_'.repeat(w=x<y?2:' 667699'[x=["BS","TAB","CAPS","ENTER"][p++]||'SHIFT',p])}\\|`,m+=y+(x+'    ').slice(0,w)+y+y,n+=y+b+y+y,l+=' __'+b)[73]&&(k.push(l,m,n,o),l='',m=n=o=y),m=n=o=y='|',p=l=k=[])&&k.join`
      // `)())

      const obj = {
        name: 'zs',
        age: '18',
        gender: '男',
      }
      function dataFormat(obj) {
        const arr = []
        for (let k in obj) {
          arr.push(k + '=' + obj[k])
        }
        return arr.join('&')
      }
      console.log(dataFormat(obj))
    </script>
  </body>
</html>
